//银银间回购
#pragma once
#include <core/sync/lock.h>
#include <qbmessage/include/message_bond.h>
#include <qbprotocol/include/SSFIModel.h>
#include <qbprotocol/include/SSMsgStruct.h>
#include <QString>
#include <set>

class MessageReceiver;
class FICIBRepoData {
public:
	typedef std::map<std::string, xQbCibRepo_c> MAP_DATA;
	typedef std::vector<std::string> VCT_IDS;
	struct iCache
	{
		time_t m_tLastUpdateTime;
		QString m_strUpdateTime;
		VCT_IDS m_vctOrder;
		MAP_DATA m_mapData;
		iCache()
		{
			m_tLastUpdateTime = 0;
			m_mapData.clear();
		}

		void clear();
		void initial();
		bool update(xQbCibRepoAck_c* pdata);
	};

public:
	FICIBRepoData();
	qb::base::Mutex& getLock() { return m_lock; };

	void clear();
	MAP_DATA& getData();
	VCT_IDS& getOrder();
	QString getLastUpdate() const;

	void reqData(MessageReceiver* msgRecv);
	bool onReceive(int32_t funcId, const qb::SSAckMsg& msg);

private:
	xQbCibRepoReq_c	m_req;
	iCache m_iCache;
	qb::base::Mutex m_lock;
};

